package com.cln.reverse_string;

import junit.framework.TestCase;

public class NumberReverserTest extends TestCase {
	public void testReverse() {
		assertEquals(1, reverse(1));
		assertEquals(23, reverse(32));
		assertEquals(234, reverse(432));
	}

	private int reverse(int i) {
		int pre = i / 10;
		int post = i % 10;
		
		if (i < 10)
			return i;
		else if (i < 100) {
			return post * 10 + reverse(pre);
		} else if (i < 1000) {
			System.out.println("pre:" + pre + " " + "post:" + post);
			return (post * 10) * 10 + reverse(pre);
		}
		return 0;
	}
}
